<!DOCTYPE html>
<html lang="en-US">
    <head>
        <title>XML::Parser - A perl module for parsing XML documents - metacpan.org</title>
        <link rel="preload" as="fetch" href="https://metacpan.org/account/login_status" crossorigin="anonymous" />
        <link href="https://metacpan.org/_assets/b8ccceeed47a0652049703d99326a9cea4933443.css" rel="stylesheet" type="text/css">
        <script src="https://metacpan.org/_assets/6bfedafe2d7caa915b7d84f61b45936818e3242e.js" type="text/javascript" defer></script>
        <link rel="alternate" type="application/rss+xml" title="Recent CPAN Uploads of XML-Parser - MetaCPAN" href="https://metacpan.org/dist/XML-Parser/releases.rss" />
        <link rel="canonical" href="./XML::Parser.html" />
        <meta name="description" content="A perl module for parsing XML documents" />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5">
        <link rel="shortcut icon" href="https://metacpan.org/static/icons/favicon.ico">
        <link rel="apple-touch-icon" sizes="152x152" href="https://metacpan.org/static/icons/apple-touch-icon.png">
        <link rel="search" href="https://metacpan.org/static/opensearch.xml" type="application/opensearchdescription+xml" title="MetaCPAN">
        <script>
          (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
          (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
          })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

          (function(skey, ga_id){
            ga('create', ga_id, {
              siteSpeedSampleRate : 100,
              storage             : 'none',
              clientId            : localStorage.getItem(skey)
            });
            ga(function(tracker) {
              localStorage.setItem(skey, tracker.get('clientId'));
            });
            ga('send', 'pageview');
          })('ga:clientId', 'UA-27829474-1');
        </script>
<meta name="twitter:card"        content="summary" />
<meta name="twitter:url"         content="https://metacpan.org/pod/XML::Parser" />
<meta name="twitter:title"       content="XML::Parser" />
<meta name="twitter:description" content="A perl module for parsing XML documents" />
<meta name="twitter:site"        content="metacpan" />
    </head>
    <body>
        <nav class="navbar navbar-default" role="navigation">
            <div class="header-logo-large hidden-xs">
              <a href="https://metacpan.org/" tabindex="0">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#logo" />
                </svg>
              </a>
            </div>
            <div class="header-logo-icon visible-xs">
              <a href="https://metacpan.org/">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#dots" />
                </svg>
              </a>
            </div>
            <ul class="nav navbar-nav menu-items hidden-xs hidden-sm">
              <li><a href="https://metacpan.org/about">About</a></li>
              <li><a href="https://metacpan.org/about/sponsors">Sponsor</a></li>
              <li><a href="https://grep.metacpan.org/">grep::cpan</a></li>
              <li><a href="https://metacpan.org/recent">Recent</a></li>
              <li><a href="https://metacpan.org/about/faq">FAQ</a></li>
              <li><a href="https://metacpan.org/tools">Tools</a></li>
              <li><a href="https://fastapi.metacpan.org/">API</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <button type="button" class="searchbar-btn visible-xs visible-sm">
                    <i class="fa fa-search button-fa-icon"></i>
                </button>
                <form action="https://metacpan.org/search" class="searchbar-form visible-md visible-lg search-form form-horizontal">
                   <input type="hidden" name="size" id="metacpan_search-size" value="20">
                  <div class="form-group">
                      <div class="search-group">
                        <i class="fa fa-search"></i>
                        <input type="text" name="q" placeholder="Search the CPAN" size="41" autocorrect="off" autocapitalize="off" spellcheck="false" id="metacpan_search-input" class="form-control" value="">
                      </div>
                  </div>
                </form>
                    <li class="icon-slidepanel visible-xs visible-sm">
                      <button data-toggle="slidepanel" data-target=".slidepanel">
                        <span class="button-fa-icon">
                          <i class="fa fa-bars slidepanel-open"></i>
                          <i class="fa fa-times slidepanel-close"></i>
                        </span>
                      </button>
                    </li>
                <form action="https://metacpan.org/account/logout" method="POST" id="metacpan-logout"></form>
                <li class="dropdown logged_in" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon logged-in-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li><a href="https://metacpan.org/account/identities">Identities</a></li>
                        <li><a href="https://metacpan.org/account/profile">Profile</a></li>
                        <li><a href="https://metacpan.org/account/favorite/list">Favorites</a></li>
                        <li>
                            <a href="./XML::Parser.html#" type="button" onclick="$('#metacpan-logout').submit(); return false">
                              Logout
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_out" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li>
                            <a href="https://metacpan.org/login/github">
                                <i class="fab fa-github fa-fw"></i>
                                GitHub
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/twitter">
                                <i class="fab fa-twitter fa-fw"></i>
                                Twitter
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/google">
                                <i class="fab fa-google fa-fw"></i>
                                Google
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_placeholder">
                    <button>
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                    </button>
                </li>
            </ul>
        </nav>
        <div class="page-content ">
          <!--
          <div class="top-notify-banner">
            <i class="fas fa-info-circle"></i>
          </div>
          -->
          <nav class="sidebar">
            <div class="slidepanel">
              <ul class="nav-list ">
    <li class="nav-header no-margin-top">
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The date that this version of XML-Parser was released.">
      <span class="relatize">29 Dec 2023 00:31:09 UTC</span>
    </li>
  <li>
    Distribution: <a href="https://metacpan.org/dist/XML-Parser">XML-Parser</a>
  </li>
  <li>
    Module version: 2.47
  </li>
  <li>
    <a data-keyboard-shortcut="g s" href="https://metacpan.org/dist/XML-Parser/source/Parser.pm">Source</a>
    (<a href="https://metacpan.org/dist/XML-Parser/source/Parser.pm?raw=1">raw</a>)
  </li>
  <li>
    <a data-keyboard-shortcut="g b" href="https://metacpan.org/dist/XML-Parser/source">Browse</a>
    (<a href="https://metacpan.org/dist/XML-Parser/source?raw=1">raw</a>)
  </li>
    <li>
      <a data-keyboard-shortcut="g c" href="https://metacpan.org/dist/XML-Parser/changes">Changes</a>
    </li>
    <li>
      <a class="nopopup" href="https://metacpan.org/dist/XML-Parser/contribute">How to Contribute</a>
    </li>
    <li>
        <a rel="noopener nofollow" data-keyboard-shortcut="g r" href="https://github.com/toddr/XML-Parser">Repository</a>
    </li>
    <li>
      <a rel="noopener nofollow" data-keyboard-shortcut="g i" href="https://github.com/toddr/XML-Parser/issues">Issues</a>
      (36)
    </li>
    <li>
      <a rel="noopener nofollow" href="http://matrix.cpantesters.org/?dist=XML-Parser+2.47" title="Matrix">Testers</a>
        <span title="(pass / fail / na)">(<a rel="noopener nofollow" href="https://www.cpantesters.org/distro/X/XML-Parser.html?oncpan=1&amp;distmat=1&amp;version=2.47&amp;grade=2" style="color: #090">905</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/X/XML-Parser.html?oncpan=1&amp;distmat=1&amp;version=2.47&amp;grade=3" style="color: #900">0</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/X/XML-Parser.html?oncpan=1&amp;distmat=1&amp;version=2.47&amp;grade=4">0</a>)</span>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://cpants.cpanauthors.org/release/TODDR/XML-Parser-2.47">Kwalitee</a>
    </li>
    <li>
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The # people with an indexing permission on XML-Parser who have released something to CPAN in the last 2 years (i.e. the # people likely able to release critical fixes in a timely manner)">
      Bus factor: 1
      </div>
    </li>
    <li>
      License: perl_5
    </li>
    <li>
      Perl: v5.4.50
    </li>
    <li class="nav-header">Activity</li>
    <li>
<div class="activity-graph">
    <img src="https://metacpan.org/dist/XML-Parser/activity.svg?res=month" />
    <div class="comment">24 month</div>
</div>
    </li>
    <li class="nav-header">Tools</li>
    <li>
      <a itemprop="downloadUrl" href="https://cpan.metacpan.org/authors/id/T/TO/TODDR/XML-Parser-2.47.tar.gz">
      Download (<span itemprop="fileSize">272.49KB</span>)</a>
    </li>
    <li>
      <a href="https://explorer.metacpan.org/?url=%2Fmodule%2FTODDR%2FXML-Parser-2.47%2FParser.pm">
        MetaCPAN Explorer
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/XML-Parser/permissions">
        Permissions
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/XML-Parser/releases.rss">
        Subscribe to distribution
      </a>
    </li>
    <li>
      <button class="btn btn-link" data-toggle="modal" data-target="#metacpan_install-instructions-dialog">
        Install Instructions
      </button>
    </li>
    <li>
      <form action="https://metacpan.org/search">
        <input type="hidden" name="q" value="dist:XML-Parser">
        <input type="search" name="q" placeholder="Search distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
      </form>
    </li>
    <li>
      <form action="https://grep.metacpan.org/search">
        <input type="hidden" name="qd" value="XML-Parser">
        <input type="hidden" name="source" value="metacpan">
        <input type="search" name="q" placeholder="grep distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
     </form>
    </li>
    <li class="version-jump">
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/Parser.pm&#39;" class="form-control tool-bar-form">
  <option disabled selected>Jump to version</option>
<option
  disabled
  value="TODDR/XML-Parser-2.47"
>2.47
  (TODDR on 2023-12-29)</option>
<option
  
  value="TODDR/XML-Parser-2.46"
>2.46
  (TODDR on 2019-09-24)</option>
<option
  
  value="CHORNY/XML-Parser-2.40"
>2.40
  (CHORNY on 2010-09-15)</option>
<option
  
  value="MSERGEANT/XML-Parser-2.36"
>2.36
  (MSERGEANT on 2007-11-20)</option>
<option
  
  value="TWEGNER/XML-Parser-2.31-bin56Mac"
>2.31-bin56Mac
  (TWEGNER on 2002-06-26)</option>
<option
  
  value="COOPERCL/XML-Parser-2.31"
>2.31
  (COOPERCL on 2002-04-02)</option>
<option
  
  value="TWEGNER/XML-Parser-2.30-bin-Mac"
>2.30-bin-Mac
  (TWEGNER on 2001-06-30)</option>
<option
  
  value="COOPERCL/XML-Parser.2.30"
>2.30
  (COOPERCL on 2000-10-05)</option>
<option
  
  value="COOPERCL/XML-Parser-2.29"
>2.29
  (COOPERCL on 2000-05-22)</option>
<option
  
  value="COOPERCL/XML-Parser-2.28"
>2.28
  (COOPERCL on 2000-03-28)</option>
<option
  
  value="ASANDSTRM/XML-Parser-2.27-bin-1-MacOS"
>2.27-bin-1-MacOS
  (ASANDSTRM on 1999-09-27)</option>
<option
  
  value="COOPERCL/XML-Parser-2.27"
>2.27
  (COOPERCL on 1999-09-25)</option>
<option
  
  value="COOPERCL/XML-Parser-2.26"
>2.26
  (COOPERCL on 1999-07-25)</option>
<option
  
  value="COOPERCL/XML-Parser-2.25"
>2.25
  (COOPERCL on 1999-07-23)</option>
<option
  
  value="COOPERCL/XML-Parser-2.24"
>2.24
  (COOPERCL on 1999-07-09)</option>
<option
  
  value="COOPERCL/XML-Parser-2.23"
>2.23
  (COOPERCL on 1999-04-27)</option>
<option
  
  value="COOPERCL/XML-Parser-2.22"
>2.22
  (COOPERCL on 1999-04-04)</option>
<option
  
  value="COOPERCL/XML-Parser-2.21"
>2.21
  (COOPERCL on 1999-03-21)</option>
<option
  
  value="COOPERCL/XML-Parser-2.20"
>2.20
  (COOPERCL on 1999-02-28)</option>
<optgroup label="BackPAN">'
<option
  
  value="TODDR/XML-Parser-2.45"
>2.45
  (TODDR on 2019-09-24)</option>
<option
  
  value="TODDR/XML-Parser-2.44_01"
>2.44_01 DEV
  (TODDR on 2016-04-13)</option>
<option
  
  value="TODDR/XML-Parser-2.44"
>2.44
  (TODDR on 2015-01-12)</option>
<option
  
  value="TODDR/XML-Parser-2.43"
>2.43
  (TODDR on 2014-12-11)</option>
<option
  
  value="TODDR/XML-Parser-2.42_01"
>2.42_01 DEV
  (TODDR on 2013-07-14)</option>
<option
  
  value="TODDR/XML-Parser-2.41"
>2.41
  (TODDR on 2011-06-03)</option>
<option
  
  value="TODDR/XML-Parser-2.40_02"
>2.40_02 DEV
  (TODDR on 2011-05-31)</option>
<option
  
  value="TODDR/XML-Parser-2.40_01"
>2.40_01 DEV
  (TODDR on 2011-05-25)</option>
<option
  
  value="MSERGEANT/XML-Parser-2.35"
>2.35
  (MSERGEANT on 2007-11-16)</option>
<option
  
  value="MSERGEANT/XML-Parser-2.34"
>2.34
  (MSERGEANT on 2003-08-18)</option>
<option
  
  value="MSERGEANT/XML-Parser-2.33"
>2.33
  (MSERGEANT on 2003-07-31)</option>
<option
  
  value="MSERGEANT/XML-Parser-2.32"
>2.32
  (MSERGEANT on 2003-07-27)</option>
<option
  
  value="TWEGNER/XML-Parser-2.30-bin56Mac"
>2.30-bin56Mac
  (TWEGNER on 2001-11-28)</option>
<option
  
  value="ASANDSTRM/XML-Parser-2.26-bin-3-MacOS"
>2.26-bin-3-MacOS
  (ASANDSTRM on 1999-08-30)</option>
<option
  
  value="ASANDSTRM/XML-Parser-2.26-bin-2-MacOS"
>2.26-bin-2-MacOS
  (ASANDSTRM on 1999-08-19)</option>
<option
  
  value="ASANDSTRM/XML-Parser-2.26-bin-1-MacOS"
>2.26-bin-1-MacOS
  (ASANDSTRM on 1999-07-28)</option>
<option
  
  value="ASANDSTRM/XML-Parser-2.23-bin-1-MacOS"
>2.23-bin-1-MacOS
  (ASANDSTRM on 1999-04-27)</option>
<option
  
  value="ASANDSTRM/XML-Parser-2.21-bin-1-MacOS"
>2.21-bin-1-MacOS
  (ASANDSTRM on 1999-03-23)</option>
<option
  
  value="CNANDOR/XML-Parser-2.20-bin-1-Mac"
>2.20-bin-1-Mac
  (CNANDOR on 1999-03-04)</option>
<option
  
  value="CNANDOR/XML-Parser-2.19-bin-1-Mac"
>2.19-bin-1-Mac
  (CNANDOR on 1999-01-26)</option>
<option
  
  value="COOPERCL/XML-Parser-2.19"
>2.19
  (COOPERCL on 1999-01-03)</option>
<option
  
  value="COOPERCL/XML-Parser-2.18"
>2.18
  (COOPERCL on 1998-12-27)</option>
<option
  
  value="COOPERCL/XML-Parser-2.17"
>2.17
  (COOPERCL on 1998-12-13)</option>
<option
  
  value="COOPERCL/XML-Parser-2.16"
>2.16
  (COOPERCL on 1998-10-28)</option>
</optgroup>
</select>
    </li>
    <li class="version-diff">
<select onchange="document.location.href='/release/TODDR/XML-Parser-2.47/diff/' + encodeURIComponent(this.value) + '/Parser.pm'
" class="form-control tool-bar-form">
  <option disabled selected>Diff with version</option>
<option
  disabled
  value="TODDR/XML-Parser-2.47"
>2.47
  (TODDR on 2023-12-29)</option>
<option
  
  value="TODDR/XML-Parser-2.46"
>2.46
  (TODDR on 2019-09-24)</option>
<option
  
  value="CHORNY/XML-Parser-2.40"
>2.40
  (CHORNY on 2010-09-15)</option>
<option
  
  value="MSERGEANT/XML-Parser-2.36"
>2.36
  (MSERGEANT on 2007-11-20)</option>
<option
  
  value="TWEGNER/XML-Parser-2.31-bin56Mac"
>2.31-bin56Mac
  (TWEGNER on 2002-06-26)</option>
<option
  
  value="COOPERCL/XML-Parser-2.31"
>2.31
  (COOPERCL on 2002-04-02)</option>
<option
  
  value="TWEGNER/XML-Parser-2.30-bin-Mac"
>2.30-bin-Mac
  (TWEGNER on 2001-06-30)</option>
<option
  
  value="COOPERCL/XML-Parser.2.30"
>2.30
  (COOPERCL on 2000-10-05)</option>
<option
  
  value="COOPERCL/XML-Parser-2.29"
>2.29
  (COOPERCL on 2000-05-22)</option>
<option
  
  value="COOPERCL/XML-Parser-2.28"
>2.28
  (COOPERCL on 2000-03-28)</option>
<option
  
  value="ASANDSTRM/XML-Parser-2.27-bin-1-MacOS"
>2.27-bin-1-MacOS
  (ASANDSTRM on 1999-09-27)</option>
<option
  
  value="COOPERCL/XML-Parser-2.27"
>2.27
  (COOPERCL on 1999-09-25)</option>
<option
  
  value="COOPERCL/XML-Parser-2.26"
>2.26
  (COOPERCL on 1999-07-25)</option>
<option
  
  value="COOPERCL/XML-Parser-2.25"
>2.25
  (COOPERCL on 1999-07-23)</option>
<option
  
  value="COOPERCL/XML-Parser-2.24"
>2.24
  (COOPERCL on 1999-07-09)</option>
<option
  
  value="COOPERCL/XML-Parser-2.23"
>2.23
  (COOPERCL on 1999-04-27)</option>
<option
  
  value="COOPERCL/XML-Parser-2.22"
>2.22
  (COOPERCL on 1999-04-04)</option>
<option
  
  value="COOPERCL/XML-Parser-2.21"
>2.21
  (COOPERCL on 1999-03-21)</option>
<option
  
  value="COOPERCL/XML-Parser-2.20"
>2.20
  (COOPERCL on 1999-02-28)</option>
<optgroup label="BackPAN">'
<option
  
  value="TODDR/XML-Parser-2.45"
>2.45
  (TODDR on 2019-09-24)</option>
<option
  
  value="TODDR/XML-Parser-2.44_01"
>2.44_01 DEV
  (TODDR on 2016-04-13)</option>
<option
  
  value="TODDR/XML-Parser-2.44"
>2.44
  (TODDR on 2015-01-12)</option>
<option
  
  value="TODDR/XML-Parser-2.43"
>2.43
  (TODDR on 2014-12-11)</option>
<option
  
  value="TODDR/XML-Parser-2.42_01"
>2.42_01 DEV
  (TODDR on 2013-07-14)</option>
<option
  
  value="TODDR/XML-Parser-2.41"
>2.41
  (TODDR on 2011-06-03)</option>
<option
  
  value="TODDR/XML-Parser-2.40_02"
>2.40_02 DEV
  (TODDR on 2011-05-31)</option>
<option
  
  value="TODDR/XML-Parser-2.40_01"
>2.40_01 DEV
  (TODDR on 2011-05-25)</option>
<option
  
  value="MSERGEANT/XML-Parser-2.35"
>2.35
  (MSERGEANT on 2007-11-16)</option>
<option
  
  value="MSERGEANT/XML-Parser-2.34"
>2.34
  (MSERGEANT on 2003-08-18)</option>
<option
  
  value="MSERGEANT/XML-Parser-2.33"
>2.33
  (MSERGEANT on 2003-07-31)</option>
<option
  
  value="MSERGEANT/XML-Parser-2.32"
>2.32
  (MSERGEANT on 2003-07-27)</option>
<option
  
  value="TWEGNER/XML-Parser-2.30-bin56Mac"
>2.30-bin56Mac
  (TWEGNER on 2001-11-28)</option>
<option
  
  value="ASANDSTRM/XML-Parser-2.26-bin-3-MacOS"
>2.26-bin-3-MacOS
  (ASANDSTRM on 1999-08-30)</option>
<option
  
  value="ASANDSTRM/XML-Parser-2.26-bin-2-MacOS"
>2.26-bin-2-MacOS
  (ASANDSTRM on 1999-08-19)</option>
<option
  
  value="ASANDSTRM/XML-Parser-2.26-bin-1-MacOS"
>2.26-bin-1-MacOS
  (ASANDSTRM on 1999-07-28)</option>
<option
  
  value="ASANDSTRM/XML-Parser-2.23-bin-1-MacOS"
>2.23-bin-1-MacOS
  (ASANDSTRM on 1999-04-27)</option>
<option
  
  value="ASANDSTRM/XML-Parser-2.21-bin-1-MacOS"
>2.21-bin-1-MacOS
  (ASANDSTRM on 1999-03-23)</option>
<option
  
  value="CNANDOR/XML-Parser-2.20-bin-1-Mac"
>2.20-bin-1-Mac
  (CNANDOR on 1999-03-04)</option>
<option
  
  value="CNANDOR/XML-Parser-2.19-bin-1-Mac"
>2.19-bin-1-Mac
  (CNANDOR on 1999-01-26)</option>
<option
  
  value="COOPERCL/XML-Parser-2.19"
>2.19
  (COOPERCL on 1999-01-03)</option>
<option
  
  value="COOPERCL/XML-Parser-2.18"
>2.18
  (COOPERCL on 1998-12-27)</option>
<option
  
  value="COOPERCL/XML-Parser-2.17"
>2.17
  (COOPERCL on 1998-12-13)</option>
<option
  
  value="COOPERCL/XML-Parser-2.16"
>2.16
  (COOPERCL on 1998-10-28)</option>
</optgroup>
</select>
    </li>

    <li>
<ul class="dependencies">
  <li class="nav-header">Dependencies</li>
  <li><a href="./LWP::UserAgent.html" title="LWP::UserAgent" class="ellipsis">LWP::UserAgent</a></li>
  <li><i class="ttip" title="dynamic_config enabled">and possibly others</i></li>
  <li>
    <hr>
  </li>
  <li>
    <a href="https://metacpan.org/module/XML::Parser/requires">Reverse dependencies</a>
  </li>
  <li>
    <a href="http://deps.cpantesters.org/?module=XML%3A%3AParser">CPAN Testers List</a>
  </li>
  <li>
    <a href="https://cpandeps.grinnz.com/?dist=XML-Parser">Dependency graph</a>
  </li>
</ul>
    </li>
    <li class="nav-header">Permalinks</li>
    <li>
      <a href="https://metacpan.org/release/TODDR/XML-Parser-2.47/view/Parser.pm">This version</a>
    </li>
    <li>
      <a href="./XML::Parser.html">Latest version</a>
    </li>
    <li>
<div class="plussers">
<div class="nav-header">++ed by:</div>
<div>
<a class="display-all" href="https://metacpan.org/author/MICHIELB"><img src="https://www.gravatar.com/avatar/c35b97da3835376f2d804b022121f962?d=identicon&amp;s=20" title="MICHIELB" alt="MICHIELB"></a>
<a class="display-all" href="https://metacpan.org/author/BKB"><img src="https://www.gravatar.com/avatar/191945c6c283d81db701008b2d89b68c?d=identicon&amp;s=20" title="BKB" alt="BKB"></a>
<a class="display-all" href="https://metacpan.org/author/PERLBOY"><img src="https://www.gravatar.com/avatar/8553a87a00c8d2efcd77fb16e6eb73c9?d=identicon&amp;s=20" title="PERLBOY" alt="PERLBOY"></a>
<a class="display-all" href="https://metacpan.org/author/KEEDI"><img src="https://www.gravatar.com/avatar/95f905a7a4ccc573c711e9d264c0fde8?d=identicon&amp;s=20" title="KEEDI" alt="KEEDI"></a>
<a class="display-all" href="https://metacpan.org/author/PINGAN"><img src="https://www.gravatar.com/avatar/a02222e5e0e4fd24d52fc29a08ac6bcb?d=identicon&amp;s=20" title="PINGAN" alt="PINGAN"></a>
</div>
<!-- Display counts of plussers-->
<div>
    <a href="https://metacpan.org/dist/XML-Parser/plussers">5 PAUSE users</a>
</div>
<div>
    5 non-PAUSE users
</div>
</div>
    </li>
    <li>
<div id="metacpan_contributors">
  <div>
    <button class="btn-link"
      onclick="$(this).hide(); $('#metacpan_contributors ul').slideDown(); return false;"
    >and 1 contributors</button>
  </div>
  <ul style="display: none">
    <li class="contributor"
    >
      Clark Cooper (coopercc@netheaven.com)
    </li>
  </ul>
</div>
    </li>
              </ul>
            </div>
          </nav>
          <div class="content-navigation">
<div class="breadcrumbs">
  <span>
    <a data-keyboard-shortcut="g a" rel="author" href="https://metacpan.org/author/TODDR" class="author-name">Todd Rinaldo</a>
  </span>
  <span>&nbsp;/&nbsp;</span>
  <div class="release dist-release status-latest maturity-released">
    <span class="dropdown"><b class="caret"></b></span>
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/Parser.pm&#39;" class="">
<option
  selected
  value="TODDR/XML-Parser-2.47"
>2.47
  (TODDR on 2023-12-29)</option>
<option
  
  value="TODDR/XML-Parser-2.46"
>2.46
  (TODDR on 2019-09-24)</option>
<option
  
  value="CHORNY/XML-Parser-2.40"
>2.40
  (CHORNY on 2010-09-15)</option>
<option
  
  value="MSERGEANT/XML-Parser-2.36"
>2.36
  (MSERGEANT on 2007-11-20)</option>
<option
  
  value="TWEGNER/XML-Parser-2.31-bin56Mac"
>2.31-bin56Mac
  (TWEGNER on 2002-06-26)</option>
<option
  
  value="COOPERCL/XML-Parser-2.31"
>2.31
  (COOPERCL on 2002-04-02)</option>
<option
  
  value="TWEGNER/XML-Parser-2.30-bin-Mac"
>2.30-bin-Mac
  (TWEGNER on 2001-06-30)</option>
<option
  
  value="COOPERCL/XML-Parser.2.30"
>2.30
  (COOPERCL on 2000-10-05)</option>
<option
  
  value="COOPERCL/XML-Parser-2.29"
>2.29
  (COOPERCL on 2000-05-22)</option>
<option
  
  value="COOPERCL/XML-Parser-2.28"
>2.28
  (COOPERCL on 2000-03-28)</option>
<option
  
  value="ASANDSTRM/XML-Parser-2.27-bin-1-MacOS"
>2.27-bin-1-MacOS
  (ASANDSTRM on 1999-09-27)</option>
<option
  
  value="COOPERCL/XML-Parser-2.27"
>2.27
  (COOPERCL on 1999-09-25)</option>
<option
  
  value="COOPERCL/XML-Parser-2.26"
>2.26
  (COOPERCL on 1999-07-25)</option>
<option
  
  value="COOPERCL/XML-Parser-2.25"
>2.25
  (COOPERCL on 1999-07-23)</option>
<option
  
  value="COOPERCL/XML-Parser-2.24"
>2.24
  (COOPERCL on 1999-07-09)</option>
<option
  
  value="COOPERCL/XML-Parser-2.23"
>2.23
  (COOPERCL on 1999-04-27)</option>
<option
  
  value="COOPERCL/XML-Parser-2.22"
>2.22
  (COOPERCL on 1999-04-04)</option>
<option
  
  value="COOPERCL/XML-Parser-2.21"
>2.21
  (COOPERCL on 1999-03-21)</option>
<option
  
  value="COOPERCL/XML-Parser-2.20"
>2.20
  (COOPERCL on 1999-02-28)</option>
<optgroup label="BackPAN">'
<option
  
  value="TODDR/XML-Parser-2.45"
>2.45
  (TODDR on 2019-09-24)</option>
<option
  
  value="TODDR/XML-Parser-2.44_01"
>2.44_01 DEV
  (TODDR on 2016-04-13)</option>
<option
  
  value="TODDR/XML-Parser-2.44"
>2.44
  (TODDR on 2015-01-12)</option>
<option
  
  value="TODDR/XML-Parser-2.43"
>2.43
  (TODDR on 2014-12-11)</option>
<option
  
  value="TODDR/XML-Parser-2.42_01"
>2.42_01 DEV
  (TODDR on 2013-07-14)</option>
<option
  
  value="TODDR/XML-Parser-2.41"
>2.41
  (TODDR on 2011-06-03)</option>
<option
  
  value="TODDR/XML-Parser-2.40_02"
>2.40_02 DEV
  (TODDR on 2011-05-31)</option>
<option
  
  value="TODDR/XML-Parser-2.40_01"
>2.40_01 DEV
  (TODDR on 2011-05-25)</option>
<option
  
  value="MSERGEANT/XML-Parser-2.35"
>2.35
  (MSERGEANT on 2007-11-16)</option>
<option
  
  value="MSERGEANT/XML-Parser-2.34"
>2.34
  (MSERGEANT on 2003-08-18)</option>
<option
  
  value="MSERGEANT/XML-Parser-2.33"
>2.33
  (MSERGEANT on 2003-07-31)</option>
<option
  
  value="MSERGEANT/XML-Parser-2.32"
>2.32
  (MSERGEANT on 2003-07-27)</option>
<option
  
  value="TWEGNER/XML-Parser-2.30-bin56Mac"
>2.30-bin56Mac
  (TWEGNER on 2001-11-28)</option>
<option
  
  value="ASANDSTRM/XML-Parser-2.26-bin-3-MacOS"
>2.26-bin-3-MacOS
  (ASANDSTRM on 1999-08-30)</option>
<option
  
  value="ASANDSTRM/XML-Parser-2.26-bin-2-MacOS"
>2.26-bin-2-MacOS
  (ASANDSTRM on 1999-08-19)</option>
<option
  
  value="ASANDSTRM/XML-Parser-2.26-bin-1-MacOS"
>2.26-bin-1-MacOS
  (ASANDSTRM on 1999-07-28)</option>
<option
  
  value="ASANDSTRM/XML-Parser-2.23-bin-1-MacOS"
>2.23-bin-1-MacOS
  (ASANDSTRM on 1999-04-27)</option>
<option
  
  value="ASANDSTRM/XML-Parser-2.21-bin-1-MacOS"
>2.21-bin-1-MacOS
  (ASANDSTRM on 1999-03-23)</option>
<option
  
  value="CNANDOR/XML-Parser-2.20-bin-1-Mac"
>2.20-bin-1-Mac
  (CNANDOR on 1999-03-04)</option>
<option
  
  value="CNANDOR/XML-Parser-2.19-bin-1-Mac"
>2.19-bin-1-Mac
  (CNANDOR on 1999-01-26)</option>
<option
  
  value="COOPERCL/XML-Parser-2.19"
>2.19
  (COOPERCL on 1999-01-03)</option>
<option
  
  value="COOPERCL/XML-Parser-2.18"
>2.18
  (COOPERCL on 1998-12-27)</option>
<option
  
  value="COOPERCL/XML-Parser-2.17"
>2.17
  (COOPERCL on 1998-12-13)</option>
<option
  
  value="COOPERCL/XML-Parser-2.16"
>2.16
  (COOPERCL on 1998-10-28)</option>
</optgroup>
</select>
    <a data-keyboard-shortcut="g d" class="release-name" href="https://metacpan.org/dist/XML-Parser">XML-Parser-2.47</a>
  </div>
<span class="river-gauge-gauge">
  <svg width="24px"
       height="15px"
       version="1.1"
       xmlns="http://www.w3.org/2000/svg"
       xmlns:xlink="http://www.w3.org/1999/xlink">

    <g>
      <title>        River stage four &#10;
          • 147 direct dependents &#10;          • 1319 total dependents
      </title>

      <rect x="0"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="5"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="10"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="15"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="20"  y="0" width="4" height="15" fill="#e4e2e2" />
    </g>
  </svg>

</span>
<div id="XML-Parser-fav" class="logged_in">
<form action="https://metacpan.org/account/favorite/add" style="display: inline" onsubmit="return favDistribution(this)">
    <input type="hidden" name="remove" value="0">
    <input type="hidden" name="release" value="XML-Parser-2.47">
    <input type="hidden" name="author" value="TODDR">
    <input type="hidden" name="distribution" value="XML-Parser">
    <button type="submit" class="favorite highlight"><span>10</span> ++</button>
</form>
</div>
<div class="logged_out">
<a href="./XML::Parser.html" onclick="alert('Please sign in to add favorites'); return false" class="favorite highlight">
<span>10</span> ++</a>
</div>
   / <span>XML::Parser</span>
</div>
          </div>
          <main class="content">


<nav class="toc">
  <div class="toc-header"><strong>Contents</strong></div>
<ul>
  <li><a href="./XML::Parser.html#NAME">NAME</a></li>
  <li><a href="./XML::Parser.html#SYNOPSIS">SYNOPSIS</a></li>
  <li><a href="./XML::Parser.html#DESCRIPTION">DESCRIPTION</a></li>
  <li><a href="./XML::Parser.html#METHODS">METHODS</a></li>
  <li><a href="./XML::Parser.html#HANDLERS">HANDLERS</a>
    <ul>
      <li><a href="./XML::Parser.html#Init-(Expat)">Init (Expat)</a></li>
      <li><a href="./XML::Parser.html#Final-(Expat)">Final (Expat)</a></li>
      <li><a href="./XML::Parser.html#Start-(Expat,-Element-%5B,-Attr,-Val-%5B,...%5D%5D)">Start (Expat, Element [, Attr, Val [,...]])</a></li>
      <li><a href="./XML::Parser.html#End-(Expat,-Element)">End (Expat, Element)</a></li>
      <li><a href="./XML::Parser.html#Char-(Expat,-String)">Char (Expat, String)</a></li>
      <li><a href="./XML::Parser.html#Proc-(Expat,-Target,-Data)">Proc (Expat, Target, Data)</a></li>
      <li><a href="./XML::Parser.html#Comment-(Expat,-Data)">Comment (Expat, Data)</a></li>
      <li><a href="./XML::Parser.html#CdataStart-(Expat)">CdataStart (Expat)</a></li>
      <li><a href="./XML::Parser.html#CdataEnd-(Expat)">CdataEnd (Expat)</a></li>
      <li><a href="./XML::Parser.html#Default-(Expat,-String)">Default (Expat, String)</a></li>
      <li><a href="./XML::Parser.html#Unparsed-(Expat,-Entity,-Base,-Sysid,-Pubid,-Notation)">Unparsed (Expat, Entity, Base, Sysid, Pubid, Notation)</a></li>
      <li><a href="./XML::Parser.html#Notation-(Expat,-Notation,-Base,-Sysid,-Pubid)">Notation (Expat, Notation, Base, Sysid, Pubid)</a></li>
      <li><a href="./XML::Parser.html#ExternEnt-(Expat,-Base,-Sysid,-Pubid)">ExternEnt (Expat, Base, Sysid, Pubid)</a></li>
      <li><a href="./XML::Parser.html#ExternEntFin-(Expat)">ExternEntFin (Expat)</a></li>
      <li><a href="./XML::Parser.html#Entity-(Expat,-Name,-Val,-Sysid,-Pubid,-Ndata,-IsParam)">Entity (Expat, Name, Val, Sysid, Pubid, Ndata, IsParam)</a></li>
      <li><a href="./XML::Parser.html#Element-(Expat,-Name,-Model)">Element (Expat, Name, Model)</a></li>
      <li><a href="./XML::Parser.html#Attlist-(Expat,-Elname,-Attname,-Type,-Default,-Fixed)">Attlist (Expat, Elname, Attname, Type, Default, Fixed)</a></li>
      <li><a href="./XML::Parser.html#Doctype-(Expat,-Name,-Sysid,-Pubid,-Internal)">Doctype (Expat, Name, Sysid, Pubid, Internal)</a></li>
      <li><a href="./XML::Parser.html#*-DoctypeFin-(Parser)">* DoctypeFin (Parser)</a></li>
      <li><a href="./XML::Parser.html#XMLDecl-(Expat,-Version,-Encoding,-Standalone)">XMLDecl (Expat, Version, Encoding, Standalone)</a></li>
    </ul>
  </li>
  <li><a href="./XML::Parser.html#STYLES">STYLES</a>
    <ul>
      <li><a href="./XML::Parser.html#Debug">Debug</a></li>
      <li><a href="./XML::Parser.html#Subs">Subs</a></li>
      <li><a href="./XML::Parser.html#Tree">Tree</a></li>
      <li><a href="./XML::Parser.html#Objects">Objects</a></li>
      <li><a href="./XML::Parser.html#Stream">Stream</a></li>
    </ul>
  </li>
  <li><a href="./XML::Parser.html#ENCODINGS">ENCODINGS</a></li>
  <li><a href="./XML::Parser.html#AUTHORS">AUTHORS</a></li>
</ul></nav>
<div class="pod anchors">
<h1 id="NAME">NAME</h1>

<p>XML::Parser - A perl module for parsing XML documents</p>

<h1 id="SYNOPSIS">SYNOPSIS</h1>

<pre><code>  use XML::Parser;

  $p1 = XML::Parser-&gt;new(Style =&gt; &#39;Debug&#39;);
  $p1-&gt;parsefile(&#39;REC-xml-19980210.xml&#39;);
  $p1-&gt;parse(&#39;&lt;foo id=&quot;me&quot;&gt;Hello World&lt;/foo&gt;&#39;);

  # Alternative
  $p2 = XML::Parser-&gt;new(Handlers =&gt; {Start =&gt; \&amp;handle_start,
                                     End   =&gt; \&amp;handle_end,
                                     Char  =&gt; \&amp;handle_char});
  $p2-&gt;parse($socket);

  # Another alternative
  $p3 = XML::Parser-&gt;new(ErrorContext =&gt; 2);

  $p3-&gt;setHandlers(Char    =&gt; \&amp;text,
                   Default =&gt; \&amp;other);

  open(my $fh, &#39;xmlgenerator |&#39;);
  $p3-&gt;parse($fh, ProtocolEncoding =&gt; &#39;ISO-8859-1&#39;);
  close($fh);

  $p3-&gt;parsefile(&#39;junk.xml&#39;, ErrorContext =&gt; 3);</code></pre>

<h1 id="DESCRIPTION">DESCRIPTION</h1>

<p>This module provides ways to parse XML documents. It is built on top of <a href="https://metacpan.org/pod/XML::Parser::Expat">XML::Parser::Expat</a>, which is a lower level interface to James Clark&#39;s expat library. Each call to one of the parsing methods creates a new instance of XML::Parser::Expat which is then used to parse the document. Expat options may be provided when the XML::Parser object is created. These options are then passed on to the Expat object on each parse call. They can also be given as extra arguments to the parse methods, in which case they override options given at XML::Parser creation time.</p>

<p>The behavior of the parser is controlled either by <code><a href="./XML::Parser.html#STYLES">&quot;STYLES&quot;</a></code> and/or <code><a href="./XML::Parser.html#HANDLERS">&quot;HANDLERS&quot;</a></code> options, or by <a href="./XML::Parser.html#setHandlers">&quot;setHandlers&quot;</a> method. These all provide mechanisms for XML::Parser to set the handlers needed by XML::Parser::Expat. If neither <code>Style</code> nor <code>Handlers</code> are specified, then parsing just checks the document for being well-formed.</p>

<p>When underlying handlers get called, they receive as their first parameter the <i>Expat</i> object, not the Parser object.</p>

<h1 id="METHODS">METHODS</h1>

<dl>

<dt id="new">new</dt>
<dd>

<p>This is a class method, the constructor for XML::Parser. Options are passed as keyword value pairs. Recognized options are:</p>

<ul>

<li><p>Style</p>

<p>This option provides an easy way to create a given style of parser. The built in styles are: <a href="./XML::Parser.html#Debug">&quot;Debug&quot;</a>, <a href="./XML::Parser.html#Subs">&quot;Subs&quot;</a>, <a href="./XML::Parser.html#Tree">&quot;Tree&quot;</a>, <a href="./XML::Parser.html#Objects">&quot;Objects&quot;</a>, and <a href="./XML::Parser.html#Stream">&quot;Stream&quot;</a>. These are all defined in separate packages under <code>XML::Parser::Style::*</code>, and you can find further documentation for each style both below, and in those packages.</p>

<p>Custom styles can be provided by giving a full package name containing at least one &#39;::&#39;. This package should then have subs defined for each handler it wishes to have installed. See <a href="./XML::Parser.html#STYLES">&quot;STYLES&quot;</a> below for a discussion of each built in style.</p>

</li>
<li><p>Handlers</p>

<p>When provided, this option should be an anonymous hash containing as keys the type of handler and as values a sub reference to handle that type of event. All the handlers get passed as their 1st parameter the instance of expat that is parsing the document. Further details on handlers can be found in <a href="./XML::Parser.html#HANDLERS">&quot;HANDLERS&quot;</a>. Any handler set here overrides the corresponding handler set with the Style option.</p>

</li>
<li><p>Pkg</p>

<p>Some styles will refer to subs defined in this package. If not provided, it defaults to the package which called the constructor.</p>

</li>
<li><p>ErrorContext</p>

<p>This is an Expat option. When this option is defined, errors are reported in context. The value should be the number of lines to show on either side of the line in which the error occurred.</p>

</li>
<li><p>ProtocolEncoding</p>

<p>This is an Expat option. This sets the protocol encoding name. It defaults to none. The built-in encodings are: <code>UTF-8</code>, <code>ISO-8859-1</code>, <code>UTF-16</code>, and <code>US-ASCII</code>. Other encodings may be used if they have encoding maps in one of the directories in the @Encoding_Path list. Check <a href="./XML::Parser.html#ENCODINGS">&quot;ENCODINGS&quot;</a> for more information on encoding maps. Setting the protocol encoding overrides any encoding in the XML declaration.</p>

</li>
<li><p>Namespaces</p>

<p>This is an Expat option. If this is set to a true value, then namespace processing is done during the parse. See <a href="https://metacpan.org/pod/XML::Parser::Expat#Namespaces">&quot;Namespaces&quot; in XML::Parser::Expat</a> for further discussion of namespace processing.</p>

</li>
<li><p>NoExpand</p>

<p>This is an Expat option. Normally, the parser will try to expand references to entities defined in the internal subset. If this option is set to a true value, and a default handler is also set, then the default handler will be called when an entity reference is seen in text. This has no effect if a default handler has not been registered, and it has no effect on the expansion of entity references inside attribute values.</p>

</li>
<li><p>Stream_Delimiter</p>

<p>This is an Expat option. It takes a string value. When this string is found alone on a line while parsing from a stream, then the parse is ended as if it saw an end of file. The intended use is with a stream of xml documents in a MIME multipart format. The string should not contain a trailing newline.</p>

</li>
<li><p>ParseParamEnt</p>

<p>This is an Expat option. Unless standalone is set to &quot;yes&quot; in the XML declaration, setting this to a true value allows the external DTD to be read, and parameter entities to be parsed and expanded.</p>

</li>
<li><p>NoLWP</p>

<p>This option has no effect if the ExternEnt or ExternEntFin handlers are directly set. Otherwise, if true, it forces the use of a file based external entity handler.</p>

</li>
<li><p>Non_Expat_Options</p>

<p>If provided, this should be an anonymous hash whose keys are options that shouldn&#39;t be passed to Expat. This should only be of concern to those subclassing XML::Parser.</p>

</li>
</ul>

</dd>
<dt id="setHandlers(TYPE,-HANDLER-[,-TYPE,-HANDLER-[...]])"><a id="setHandlers"></a><a id="setHandlers-TYPE--HANDLER---TYPE--HANDLER"></a>setHandlers(TYPE, HANDLER [, TYPE, HANDLER [...]])</dt>
<dd>

<p>This method registers handlers for various parser events. It overrides any previous handlers registered through the Style or Handler options or through earlier calls to setHandlers. By providing a false or undefined value as the handler, the existing handler can be unset.</p>

<p>This method returns a list of type, handler pairs corresponding to the input. The handlers returned are the ones that were in effect prior to the call.</p>

<p>See a description of the handler types in <a href="./XML::Parser.html#HANDLERS">&quot;HANDLERS&quot;</a>.</p>

</dd>
<dt id="parse(SOURCE-[,-OPT-=&gt;-OPT_VALUE-[...]])"><a id="parse"></a><a id="parse-SOURCE---OPT---OPT_VALUE"></a>parse(SOURCE [, OPT =&gt; OPT_VALUE [...]])</dt>
<dd>

<p>The SOURCE parameter should either be a string containing the whole XML document, or it should be an open IO::Handle. Constructor options to XML::Parser::Expat given as keyword-value pairs may follow the SOURCE parameter. These override, for this call, any options or attributes passed through from the XML::Parser instance.</p>

<p>A die call is thrown if a parse error occurs. Otherwise it will return 1 or whatever is returned from the <b>Final</b> handler, if one is installed. In other words, what parse may return depends on the style.</p>

</dd>
<dt id="parsestring">parsestring</dt>
<dd>

<p>This is just an alias for parse for backwards compatibility.</p>

</dd>
<dt id="parsefile(FILE-[,-OPT-=&gt;-OPT_VALUE-[...]])"><a id="parsefile"></a><a id="parsefile-FILE---OPT---OPT_VALUE"></a>parsefile(FILE [, OPT =&gt; OPT_VALUE [...]])</dt>
<dd>

<p>Open FILE for reading, then call parse with the open handle. The file is closed no matter how parse returns. Returns what parse returns.</p>

</dd>
<dt id="parse_start([-OPT-=&gt;-OPT_VALUE-[...]])"><a id="parse_start"></a><a id="parse_start--OPT---OPT_VALUE"></a>parse_start([ OPT =&gt; OPT_VALUE [...]])</dt>
<dd>

<p>Create and return a new instance of XML::Parser::ExpatNB. Constructor options may be provided. If an init handler has been provided, it is called before returning the ExpatNB object. Documents are parsed by making incremental calls to the parse_more method of this object, which takes a string. A single call to the parse_done method of this object, which takes no arguments, indicates that the document is finished.</p>

<p>If there is a final handler installed, it is executed by the parse_done method before returning and the parse_done method returns whatever is returned by the final handler.</p>

</dd>
</dl>

<h1 id="HANDLERS">HANDLERS</h1>

<p>Expat is an event based parser. As the parser recognizes parts of the document (say the start or end tag for an XML element), then any handlers registered for that type of an event are called with suitable parameters. All handlers receive an instance of XML::Parser::Expat as their first argument. See <a href="https://metacpan.org/pod/XML::Parser::Expat#METHODS">&quot;METHODS&quot; in XML::Parser::Expat</a> for a discussion of the methods that can be called on this object.</p>

<h2 id="Init-(Expat)"><a id="Init"></a><a id="Init--Expat"></a>Init (Expat)</h2>

<p>This is called just before the parsing of the document starts.</p>

<h2 id="Final-(Expat)"><a id="Final"></a><a id="Final--Expat"></a>Final (Expat)</h2>

<p>This is called just after parsing has finished, but only if no errors occurred during the parse. Parse returns what this returns.</p>

<h2 id="Start-(Expat,-Element-[,-Attr,-Val-[,...]])"><a id="Start"></a><a id="Start--Expat--Element---Attr--Val"></a>Start (Expat, Element [, Attr, Val [,...]])</h2>

<p>This event is generated when an XML start tag is recognized. Element is the name of the XML element type that is opened with the start tag. The Attr &amp; Val pairs are generated for each attribute in the start tag.</p>

<h2 id="End-(Expat,-Element)"><a id="End"></a><a id="End--Expat--Element"></a>End (Expat, Element)</h2>

<p>This event is generated when an XML end tag is recognized. Note that an XML empty tag (&lt;foo/&gt;) generates both a start and an end event.</p>

<h2 id="Char-(Expat,-String)"><a id="Char"></a><a id="Char--Expat--String"></a>Char (Expat, String)</h2>

<p>This event is generated when non-markup is recognized. The non-markup sequence of characters is in String. A single non-markup sequence of characters may generate multiple calls to this handler. Whatever the encoding of the string in the original document, this is given to the handler in UTF-8.</p>

<h2 id="Proc-(Expat,-Target,-Data)"><a id="Proc"></a><a id="Proc--Expat--Target--Data"></a>Proc (Expat, Target, Data)</h2>

<p>This event is generated when a processing instruction is recognized.</p>

<h2 id="Comment-(Expat,-Data)"><a id="Comment"></a><a id="Comment--Expat--Data"></a>Comment (Expat, Data)</h2>

<p>This event is generated when a comment is recognized.</p>

<h2 id="CdataStart-(Expat)"><a id="CdataStart"></a><a id="CdataStart--Expat"></a>CdataStart (Expat)</h2>

<p>This is called at the start of a CDATA section.</p>

<h2 id="CdataEnd-(Expat)"><a id="CdataEnd"></a><a id="CdataEnd--Expat"></a>CdataEnd (Expat)</h2>

<p>This is called at the end of a CDATA section.</p>

<h2 id="Default-(Expat,-String)"><a id="Default"></a><a id="Default--Expat--String"></a>Default (Expat, String)</h2>

<p>This is called for any characters that don&#39;t have a registered handler. This includes both characters that are part of markup for which no events are generated (markup declarations) and characters that could generate events, but for which no handler has been registered.</p>

<p>Whatever the encoding in the original document, the string is returned to the handler in UTF-8.</p>

<h2 id="Unparsed-(Expat,-Entity,-Base,-Sysid,-Pubid,-Notation)"><a id="Unparsed"></a><a id="Unparsed--Expat--Entity--Base--Sysid--Pubid--Notation"></a>Unparsed (Expat, Entity, Base, Sysid, Pubid, Notation)</h2>

<p>This is called for a declaration of an unparsed entity. Entity is the name of the entity. Base is the base to be used for resolving a relative URI. Sysid is the system id. Pubid is the public id. Notation is the notation name. Base and Pubid may be undefined.</p>

<h2 id="Notation-(Expat,-Notation,-Base,-Sysid,-Pubid)"><a id="Notation"></a><a id="Notation--Expat--Notation--Base--Sysid--Pubid"></a>Notation (Expat, Notation, Base, Sysid, Pubid)</h2>

<p>This is called for a declaration of notation. Notation is the notation name. Base is the base to be used for resolving a relative URI. Sysid is the system id. Pubid is the public id. Base, Sysid, and Pubid may all be undefined.</p>

<h2 id="ExternEnt-(Expat,-Base,-Sysid,-Pubid)"><a id="ExternEnt"></a><a id="ExternEnt--Expat--Base--Sysid--Pubid"></a>ExternEnt (Expat, Base, Sysid, Pubid)</h2>

<p>This is called when an external entity is referenced. Base is the base to be used for resolving a relative URI. Sysid is the system id. Pubid is the public id. Base, and Pubid may be undefined.</p>

<p>This handler should either return a string, which represents the contents of the external entity, or return an open filehandle that can be read to obtain the contents of the external entity, or return undef, which indicates the external entity couldn&#39;t be found and will generate a parse error.</p>

<p>If an open filehandle is returned, it must be returned as either a glob (*FOO) or as a reference to a glob (e.g. an instance of IO::Handle).</p>

<p>A default handler is installed for this event. The default handler is XML::Parser::lwp_ext_ent_handler unless the NoLWP option was provided with a true value, otherwise XML::Parser::file_ext_ent_handler is the default handler for external entities. Even without the NoLWP option, if the URI or LWP modules are missing, the file based handler ends up being used after giving a warning on the first external entity reference.</p>

<p>The LWP external entity handler will use proxies defined in the environment (http_proxy, ftp_proxy, etc.).</p>

<p>Please note that the LWP external entity handler reads the entire entity into a string and returns it, where as the file handler opens a filehandle.</p>

<p>Also note that the file external entity handler will likely choke on absolute URIs or file names that don&#39;t fit the conventions of the local operating system.</p>

<p>The expat base method can be used to set a basename for relative pathnames. If no basename is given, or if the basename is itself a relative name, then it is relative to the current working directory.</p>

<h2 id="ExternEntFin-(Expat)"><a id="ExternEntFin"></a><a id="ExternEntFin--Expat"></a>ExternEntFin (Expat)</h2>

<p>This is called after parsing an external entity. It&#39;s not called unless an ExternEnt handler is also set. There is a default handler installed that pairs with the default ExternEnt handler.</p>

<p>If you&#39;re going to install your own ExternEnt handler, then you should set (or unset) this handler too.</p>

<h2 id="Entity-(Expat,-Name,-Val,-Sysid,-Pubid,-Ndata,-IsParam)"><a id="Entity"></a><a id="Entity--Expat--Name--Val--Sysid--Pubid--Ndata--IsParam"></a>Entity (Expat, Name, Val, Sysid, Pubid, Ndata, IsParam)</h2>

<p>This is called when an entity is declared. For internal entities, the Val parameter will contain the value and the remaining three parameters will be undefined. For external entities, the Val parameter will be undefined, the Sysid parameter will have the system id, the Pubid parameter will have the public id if it was provided (it will be undefined otherwise), the Ndata parameter will contain the notation for unparsed entities. If this is a parameter entity declaration, then the IsParam parameter is true.</p>

<p>Note that this handler and the Unparsed handler above overlap. If both are set, then this handler will not be called for unparsed entities.</p>

<h2 id="Element-(Expat,-Name,-Model)"><a id="Element"></a><a id="Element--Expat--Name--Model"></a>Element (Expat, Name, Model)</h2>

<p>The element handler is called when an element declaration is found. Name is the element name, and Model is the content model as an XML::Parser::Content object. See <a href="https://metacpan.org/pod/XML::Parser::Expat#XML::Parser::ContentModel-Methods">&quot;XML::Parser::ContentModel Methods&quot; in XML::Parser::Expat</a> for methods available for this class.</p>

<h2 id="Attlist-(Expat,-Elname,-Attname,-Type,-Default,-Fixed)"><a id="Attlist"></a><a id="Attlist--Expat--Elname--Attname--Type--Default--Fixed"></a>Attlist (Expat, Elname, Attname, Type, Default, Fixed)</h2>

<p>This handler is called for each attribute in an ATTLIST declaration. So an ATTLIST declaration that has multiple attributes will generate multiple calls to this handler. The Elname parameter is the name of the element with which the attribute is being associated. The Attname parameter is the name of the attribute. Type is the attribute type, given as a string. Default is the default value, which will either be &quot;#REQUIRED&quot;, &quot;#IMPLIED&quot; or a quoted string (i.e. the returned string will begin and end with a quote character). If Fixed is true, then this is a fixed attribute.</p>

<h2 id="Doctype-(Expat,-Name,-Sysid,-Pubid,-Internal)"><a id="Doctype"></a><a id="Doctype--Expat--Name--Sysid--Pubid--Internal"></a>Doctype (Expat, Name, Sysid, Pubid, Internal)</h2>

<p>This handler is called for DOCTYPE declarations. Name is the document type name. Sysid is the system id of the document type, if it was provided, otherwise it&#39;s undefined. Pubid is the public id of the document type, which will be undefined if no public id was given. Internal is the internal subset, given as a string. If there was no internal subset, it will be undefined. Internal will contain all whitespace, comments, processing instructions, and declarations seen in the internal subset. The declarations will be there whether or not they have been processed by another handler (except for unparsed entities processed by the Unparsed handler). However, comments and processing instructions will not appear if they&#39;ve been processed by their respective handlers.</p>

<h2 id="*-DoctypeFin-(Parser)"><a id="DoctypeFin--Parser"></a>* DoctypeFin (Parser)</h2>

<p>This handler is called after parsing of the DOCTYPE declaration has finished, including any internal or external DTD declarations.</p>

<h2 id="XMLDecl-(Expat,-Version,-Encoding,-Standalone)"><a id="XMLDecl"></a><a id="XMLDecl--Expat--Version--Encoding--Standalone"></a>XMLDecl (Expat, Version, Encoding, Standalone)</h2>

<p>This handler is called for xml declarations. Version is a string containing the version. Encoding is either undefined or contains an encoding string. Standalone will be either true, false, or undefined if the standalone attribute is yes, no, or not made respectively.</p>

<h1 id="STYLES">STYLES</h1>

<h2 id="Debug">Debug</h2>

<p>This just prints out the document in outline form. Nothing special is returned by parse.</p>

<h2 id="Subs">Subs</h2>

<p>Each time an element starts, a sub by that name in the package specified by the Pkg option is called with the same parameters that the Start handler gets called with.</p>

<p>Each time an element ends, a sub with that name appended with an underscore (&quot;_&quot;), is called with the same parameters that the End handler gets called with.</p>

<p>Nothing special is returned by parse.</p>

<h2 id="Tree">Tree</h2>

<p>Parse will return a parse tree for the document. Each node in the tree takes the form of a tag, content pair. Text nodes are represented with a pseudo-tag of &quot;0&quot; and the string that is their content. For elements, the content is an array reference. The first item in the array is a (possibly empty) hash reference containing attributes. The remainder of the array is a sequence of tag-content pairs representing the content of the element.</p>

<p>So for example the result of parsing:</p>

<pre><code>  &lt;foo&gt;&lt;head id=&quot;a&quot;&gt;Hello &lt;em&gt;there&lt;/em&gt;&lt;/head&gt;&lt;bar&gt;Howdy&lt;ref/&gt;&lt;/bar&gt;do&lt;/foo&gt;</code></pre>

<p>would be:</p>

<pre><code>             Tag   Content
  ==================================================================
  [foo, [{}, head, [{id =&gt; &quot;a&quot;}, 0, &quot;Hello &quot;,  em, [{}, 0, &quot;there&quot;]],
              bar, [         {}, 0, &quot;Howdy&quot;,  ref, [{}]],
                0, &quot;do&quot;
        ]
  ]</code></pre>

<p>The root document &quot;foo&quot;, has 3 children: a &quot;head&quot; element, a &quot;bar&quot; element and the text &quot;do&quot;. After the empty attribute hash, these are represented in it&#39;s contents by 3 tag-content pairs.</p>

<h2 id="Objects">Objects</h2>

<p>This is similar to the Tree style, except that a hash object is created for each element. The corresponding object will be in the class whose name is created by appending &quot;::&quot; and the element name to the package set with the Pkg option. Non-markup text will be in the ::Characters class. The contents of the corresponding object will be in an anonymous array that is the value of the Kids property for that object.</p>

<h2 id="Stream">Stream</h2>

<p>This style also uses the Pkg package. If none of the subs that this style looks for is there, then the effect of parsing with this style is to print a canonical copy of the document without comments or declarations. All the subs receive as their 1st parameter the Expat instance for the document they&#39;re parsing.</p>

<p>It looks for the following routines:</p>

<ul>

<li><p>StartDocument</p>

<p>Called at the start of the parse .</p>

</li>
<li><p>StartTag</p>

<p>Called for every start tag with a second parameter of the element type. The $_ variable will contain a copy of the tag and the %_ variable will contain attribute values supplied for that element.</p>

</li>
<li><p>EndTag</p>

<p>Called for every end tag with a second parameter of the element type. The $_ variable will contain a copy of the end tag.</p>

</li>
<li><p>Text</p>

<p>Called just before start or end tags with accumulated non-markup text in the $_ variable.</p>

</li>
<li><p>PI</p>

<p>Called for processing instructions. The $_ variable will contain a copy of the PI and the target and data are sent as 2nd and 3rd parameters respectively.</p>

</li>
<li><p>EndDocument</p>

<p>Called at conclusion of the parse.</p>

</li>
</ul>

<h1 id="ENCODINGS">ENCODINGS</h1>

<p>XML documents may be encoded in character sets other than Unicode as long as they may be mapped into the Unicode character set. Expat has further restrictions on encodings. Read the xmlparse.h header file in the expat distribution to see details on these restrictions.</p>

<p>Expat has built-in encodings for: <code>UTF-8</code>, <code>ISO-8859-1</code>, <code>UTF-16</code>, and <code>US-ASCII</code>. Encodings are set either through the XML declaration encoding attribute or through the ProtocolEncoding option to XML::Parser or XML::Parser::Expat.</p>

<p>For encodings other than the built-ins, expat calls the function load_encoding in the Expat package with the encoding name. This function looks for a file in the path list @XML::Parser::Expat::Encoding_Path, that matches the lower-cased name with a &#39;.enc&#39; extension. The first one it finds, it loads.</p>

<p>If you wish to build your own encoding maps, check out the XML::Encoding module from CPAN.</p>

<h1 id="AUTHORS">AUTHORS</h1>

<p>Larry Wall &lt;<i>larry@wall.org</i>&gt; wrote version 1.0.</p>

<p>Clark Cooper &lt;<i>coopercc@netheaven.com</i>&gt; picked up support, changed the API for this version (2.x), provided documentation, and added some standard package features.</p>

<p>Matt Sergeant &lt;<i>matt@sergeant.org</i>&gt; is now maintaining XML::Parser</p></div>

<div id="metacpan_install-instructions-dialog" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">Module Install Instructions</h4>
      </div>
      <div class="modal-body">
        <p>To install XML::Parser, copy and paste the appropriate command in to your terminal.</p>
        <p><a href="https://metacpan.org/dist/App-cpanminus/view/bin/cpanm">cpanm</a></p>
        <pre><code>cpanm XML::Parser</code></pre>
        <p><a href="https://metacpan.org/pod/CPAN">CPAN shell</a></p>
        <pre><code>perl -MCPAN -e shell
install XML::Parser</code></pre>
        <p>For more information on module installation, please visit <a href="https://www.cpan.org/modules/INSTALL.html">the detailed CPAN module installation guide</a>.</p>
      </div>
      <div class="modal-footer">
        <a href="./XML::Parser.html#" data-dismiss="modal" class="btn">Close</a>
      </div>
    </div>
  </div>
</div>
          </main>
          <div class="content-pagination">
          </div>
        </div>
        <footer class="footer">
          <div class="footer-container">
            <div class="footer-social">
              <div class="footer-link footer-logo">
                <a href="https://metacpan.org/">
                  <img src="https://metacpan.org/static/images/metacpan-logo.svg" alt="MetaCPAN" />
                </a>
              </div>
              <a class="footer-social-link" href="https://github.com/metacpan">
                <i class="fab fa-github-square"></i>
              </a>
              <a class="footer-social-link" href="https://fosstodon.org/@metacpan">
                <i class="fab fa-mastodon"></i>
              </a>
            </div>
            <div class="footer-links">
              <div class="footer-link">
                  <a href="https://metacpan.org/about">About</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/sponsors">Sponsor</a>
              </div>
              <div class="footer-link">
                  <a href="https://grep.metacpan.org">grep::cpan</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/recent">Recent</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/faq">FAQ</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/tools">Tools</a>
              </div>
              <div class="footer-link">
                  <a href="https://fastapi.metacpan.org/">API</a>
              </div>
              <div class="footer-link">
                  <a href="https://www.perl.org/">Perl.org</a>
              </div>
            </div>
            <div class="footer-sponsors">
              <a class="footer-sponsor-link" target="_blank" href="https://www.bytemark.co.uk/" rel="noopener">
                <img class="footer-sponsor-bytemark" src="https://metacpan.org/static/images/sponsors/bytemark_logo.svg" alt="Bytemark logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.liquidweb.com/" rel="noopener">
                <img class="footer-sponsor-liquidweb" src="https://metacpan.org/static/images/sponsors/liquidweb_logo.png" alt="liquidweb logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://deriv.com/careers/" rel="noopener">
                <img class="footer-sponsor-deriv" src="https://metacpan.org/static/images/sponsors/deriv.svg" alt="Deriv logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://geocode.xyz" rel="noopener">
                <img class="footer-sponsor-geocode" src="https://metacpan.org/static/images/sponsors/geocodelogo.svg" alt="Geocode logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.fastly.com/" rel="noopener">
                <img class="footer-sponsor-fastly" src="https://metacpan.org/static/images/sponsors/fastly_logo.svg" alt="Fastly logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://opencagedata.com" rel="noopener">
                <img class="footer-sponsor-opencage" src="https://metacpan.org/static/images/sponsors/open-cage.svg" alt="OpenCage logo">
              </a>
            </div>
          </div>
        </footer>
        <div class="modal fade" tabindex="-1" role="dialog" id="metacpan_keyboard-shortcuts">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Keyboard Shortcuts</h4>
              </div>
              <div class="modal-body row">
<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Global</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>s</kbd>
        </td>
        <td>Focus search bar</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>?</kbd>
        </td>
        <td>Bring up this help dialog</td>
      </tr>
    </tbody>
  </table>

  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>GitHub</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>p</kbd>
        </td>
        <td>Go to pull requests</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>go to github issues (only if github is preferred repository)</td>
      </tr>
    </tbody>
  </table>
</div>

<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>POD</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>a</kbd>
        </td>
        <td>Go to author</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>c</kbd>
        </td>
        <td>Go to changes</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>Go to issues</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>d</kbd>
        </td>
        <td>Go to dist</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>r</kbd>
        </td>
        <td>Go to repository/SCM</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>s</kbd>
        </td>
        <td>Go to source</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>b</kbd>
        </td>
        <td>Go to file browse</td>
      </tr>

    </tbody>
  </table>
</div>

<div class="col-md-12">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Search terms</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><em>module:</em> (e.g. <a href="https://metacpan.org/search?q=module%3APlugin">module:Plugin</a>)</td>
      </tr>
      <tr>
        <td><em>distribution:</em> (e.g. <a href="https://metacpan.org/search?q=distribution%3ADancer+auth">distribution:Dancer auth</a>)</td>
      </tr>
      <tr>
        <td><em>author:</em> (e.g. <a href="https://metacpan.org/search?q=author%3ASONGMU+Redis">author:SONGMU Redis</a>)</td>
      </tr>
      <tr>
        <td><em>version:</em> (e.g. <a href="https://metacpan.org/search?q=version%3A1.00">version:1.00</a>)</td>
      </tr>
    </tbody>
  </table>
</div>
              </div>
              <div class="modal-footer"></div>
            </div>
          </div>
        </div>
    </body>
</html>
